package com.lagou.edu.mapper;

import com.lagou.edu.dao.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * @Classname IUserMapper
 * @Date 2021/5/30 16:49
 * @Author ch'ien
 */

@Repository
public interface IUserMapper {

    @Select("select * from user where email =  #{email} and password = #{password} limit 1")
    User getByEmailAndPassWord(@Param("email")String email, @Param("password") String password);

    @Select("select count(id) from user where email =  #{email} ")
    int isRegistered(String email);

    @Insert("insert into user (email, password) value (#{email},#{password}) ")
    int save(@Param("email") String email, @Param("password")  String password);
}
